
import {api} from './libs/api.js';
let _self;
export const index =  {
	data() {
		return {
			optLock:false,
			code:"",
			formData:{},
			params:{},
			userInfo: {},
			formField:[]

		}
	},
	
	mounted() {
		_self = this;
	},
	onReachBottom:function(e){
		/*this.params.page+=1;
		this.initData();*/
	},
	
	onLoad:function(option) {
		this.params=option;
	},
	
	onReady() {  
		this.initData();
	},
	
	
	methods: {
		async initData(){
			if(this.params["user_id"]){
				this.formField=await api.customerQrForm(this.params);
			}
		},
		
		async getUserProfile(e) {
			if(this.optLock){
				uni.showToast({icon:"none",title:"请不要重复提交！"});
				return false;
			}
			this.optLock=true;
		    uni.getUserProfile({
				desc: '用于用户授权下单', 
				success: (res) => {
					_self.userInfo=res.userInfo;
					_self.setAuthData();
				}
		    })
		},
		
		async setAuthData(){
		    let ret=await api.setCustomerQrcode({
				"user_id":this.params["user_id"],
				"product_id":this.params["product_id"],
				"tel":this.formData["tel"],
				"nickname":this.userInfo["nickName"]
			});
		}
		
			
	},
}